package com.example.practice.activity;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.widget.TextView;

import com.example.practice.MainActivity;
import com.example.practice.R;

import java.util.Timer;
import java.util.TimerTask;

public class welcomeActivity extends AppCompatActivity {
    TextView tvVersion;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_welcome);
        initView();
    }

//    初始化版本号
    private void initView() {
        tvVersion = findViewById(R.id.tv_version);

        try {
            PackageInfo info = getPackageManager().getPackageInfo(getPackageName(),0);
            tvVersion.setText("V" + info.versionName);
        } catch (PackageManager.NameNotFoundException e) {
            tvVersion.setText("V0.0");
        }

        Timer timer = new Timer();
        TimerTask task = new TimerTask() {
            @Override
            public void run() {
                Intent intent = new Intent(welcomeActivity.this, MainActivity.class);
                startActivity(intent);
                welcomeActivity.this.finish();
            }
        };
        timer.schedule(task,5000);
    }


}